public class CalculateTax {

    public double calculateTax(int[][] brackets, int income) {
        if (income <= brackets[0][0]) return income * brackets[0][1] * 0.01;
        double ans = brackets[0][1] * brackets[0][0] * 0.01;
        for (int i = 1; i < brackets.length; i++) {
            if (income <= brackets[i][0]) {
                ans += (income - brackets[i - 1][0]) * 0.01 * brackets[i][1];
                break;
            } else {
                ans += (brackets[i][0] - brackets[i - 1][0]) * 0.01 * brackets[i][1];
            }
        }
        return ans;
    }
}
